﻿#Include ..\baseHandle.ahk
#Include ..\..\core\historyMgr.ahk

class Hist extends BaseHandle {

  static Handle(parsed) {
    switch parsed.target {
      case 'open': History.OpenFile()
      case 'clear': History.Clear()
      case 'list':
        return this.Succ('10 of ' History.hist.Length '`n'  History.hist.slice(-10).Join('`n'))
      default: return this.Fail('无效的操作')
    }
    return this.Succ('ok', 'x')
  }

  static Spec() {
    return {
      cmd: 'hist',
      desc: '管理历史命令',
      format: 'hist <open|clear|list>',
      args: {
        desc: '打开或清理文件',
        isOptional: false,
        cacheable: true,
        fixed: true,
        generator: {
          script: '',
          postProcess: (*) => ['open', 'clear', 'list']
        }
      },
      extra: {
        isEnable: false
      }
    }
  }
}
